<template>
	<MyPage title="兑换会员" :isback="true">
		<view slot="gBody">
			<view class="exchange">
				<u-form :model="form" ref="uForm">
					<u-form-item prop="pwd">
						<u-input v-model="form.pwd" placeholder="请输入兑换密码" maxlength="20" :trim="true" />
					</u-form-item>
					<MyBtn title="立即兑换" @click="formSubmit"></MyBtn>
				</u-form>
				<view class="grey content">
					<view class="title">说明：</view>
					1.仅限线下会员实体卡兑换，兑换后立即生效。<br/>
					2.请在有效期内兑换会员、<br/>
					3.实体卡为虚拟产品，请尽快兑换使用。<br/>
					4.如有问题，请与 <text class="blue" @click="$utils.navigateTo('/agreement/agreement',{id:50})">我们联系</text>。
				</view>
			</view>
		</view>
	</MyPage>
</template>		
 	
<script>
 
import { getCityList } from '@/api/compute.js'
export default {
 
	data() {
		return {
			form: {
				pwd: ''
			},
			rules: {
				pwd: [
					{
						required: true,
						message: '请输入兑换密码',
						trigger: ['change','blur']
					},
					{
						min: 10,
						message: '密码不能少于6位数',
						trigger: 'change'
					}
				]
			}
		}
	},
	onReady() {
		this.$refs.uForm.setRules(this.rules);  //验证初始化
	},
	methods: {
		// 提交
		formSubmit(){
			this.$refs.uForm.validate(valid => {
				if (valid) {
					uni.request({
						url: 'http://www.txzh.com.cn/api.php?app=Default&act=submitjh',  
						method: 'POST',
						data:{
							token:this.$store.state.app.token,
							pwd:this.form.pwd
						},
						header: {
							'Content-Type': 'application/x-www-form-urlencoded',
							'X-Requested-With': 'xmlhttprequest'
						},
						success: res => {
							if(res.data.list.err==0){
								uni.showToast({
									title: "激活成功",
									icon: "none",
									duration: 2000
								});
								this.show = 0;
							}else{
								uni.showToast({
									title: res.data.list.msg,
									icon: "none",
									duration: 2000
								});
								this.show = 0;
							}
							 
						},  
						fail: () => {},  
						complete: () => {}  
					});
				}
			});
		}
	}
}
</script>

<style lang="scss" scoped>
.exchange{
	padding:50rpx 50rpx 50rpx;
}
.content{
	margin-top:30rpx;
	line-height: 1.8em;
	font-size:24rpx;
	.title{
		font-size:28rpx;
		font-weight: bold;
	}
}
</style>